use actix_web::{error::ErrorInternalServerError, web, Responder, Result};

use crate::{
    api_add, api_delete, api_edit,
    database::DbPool,
    route::form::menu::{MenuForm, NewMenuForm},
    service::class,
};

pub fn config_admin_menu(cfg: &mut web::ServiceConfig) {
    cfg.service(
        web::scope("/menu")
            .route("/add", web::post().to(add_menu))
            .route("/edit", web::post().to(edit_menu))
            .route("/delete", web::post().to(delete_menu)),
    );
}

api_add!(add_menu, NewMenuForm, class::menu::add);
api_edit!(edit_menu, MenuForm, class::menu::upd);
api_delete!(delete_menu, MenuForm, class::menu::del);
